<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${basePackage}.${mapperPackage}.${className}Mapper">

    <resultMap id="${className?uncap_first}" type="${basePackage}.${entityPackage}.${className}">
        <#if columns??>
        <#list columns as column>
            <#if column.isKey = true>
        <id column="${column.name}" jdbcType="${column.type}" property="${column.field?uncap_first}"/>
            <#else>
        <result column="${column.name}" jdbcType="${column.type}" property="${column.field?uncap_first}"/>
            </#if>
        </#list>
        </#if>
    </resultMap>
    <select id="find${className}DetailPageByMap" parameterType="map" resultType="cc.mrbird.febs.buss.entity.${className}">
        select * from
        ${tableName} t
        where 1=1
        <#if columns??>
            <#list columns as column>
                <if test="map.${column.field?uncap_first} != null and map.${column.field?uncap_first} != ''">
                    AND t.${column.name}=${r"#{"}map.${column.field?uncap_first}${r"}"}
                </if>
            </#list>
        </#if>
    </select>

    <insert id="insertOne" parameterType="cc.mrbird.febs.buss.entity.${className}">
        insert into ${tableName} (
        <#if columns??>
            <#list columns as column>
                ${column.name}
                <#if column_has_next>,</#if>
            </#list>
        </#if>
        )
        values (
        <#if columns??>
        <#list columns as column>
            ${r"#{"}${column.field?uncap_first},jdbcType=${column.type}${r"}"}
            <#if column_has_next>,</#if>
        </#list>
        </#if>
        )
    </insert>
    <select id="selectByMap" parameterType="map" resultType="cc.mrbird.febs.buss.entity.${className}">
        select * from
        ${tableName} t
        where 1=1
        <#if columns??>
            <#list columns as column>
                <if test="map.${column.field?uncap_first} != null and map.${column.field?uncap_first} != ''">
                    AND t.${column.name}=${r"#{"}map.${column.field?uncap_first}${r"}"}
                </if>
            </#list>
        </#if>

    </select>
</mapper>
